import { defHttp } from '/@/utils/http/axios';
import { IdModel } from '/@/api/model/baseModel';
import {
  DictionaryItemListModel,
  DictionaryItemListQueryParam,
} from '/@/views/system/dictionary/model/item';
import { DictionaryItemSaveModel } from '/@/views/system/dictionary/model/item';

enum Api {
  GetList = '/dictionary/item/find',
  Save = '/dictionary/item/save',
  Update = '/dictionary/item/update',
  Del = '/dictionary/item/delete',
}

/**
 * @description: 列表
 */
export const getList = (params: DictionaryItemListQueryParam) => {
  return defHttp.get<DictionaryItemListModel[]>({ url: Api.GetList, params });
};

/**
 * @description: 保存
 */
export const save = (params: DictionaryItemSaveModel) => {
  return defHttp.post<DictionaryItemSaveModel>({
    url: Api.Save,
    params,
  });
};

/**
 * @description: 更新
 */
export const update = (params: DictionaryItemSaveModel) => {
  return defHttp.post<DictionaryItemSaveModel>({
    url: Api.Update,
    params,
  });
};

/**
 * @description: 删除
 */
export const del = (params: IdModel) => {
  return defHttp.delete<IdModel>({
    url: `${Api.Del}?id=${params.id}`,
  });
};
